package 力扣;

/**
 * @author yyq
 * @create 2022-03-05 11:00
 */
public class leetcode209 {
    public static void main(String[] args) {
        int[] nums={1,1,1,1,7};
        System.out.println(minSubArrayLen(7, nums));
    }
    public static int minSubArrayLen(int target, int[] nums) {
        int miniLength=0;
        for (int i = 0; i < nums.length; i++) {
            int count=1;
            int sum=nums[i];
            for(int j=i;j< nums.length;j++){
                if(sum<target){
                    if(j+1<nums.length) sum=sum+nums[j+1];
                    count++;
                }
                if(sum>=target){
                    if(miniLength==0){
                        miniLength=count;
                    }
                    if(miniLength>count){
                        miniLength=count;
                        break;
                    }
                }
            }
        }
        return miniLength;
    }
}
